// pages/myCenter/panelData/panelData.js
const app = getApp();
import Common from '../../../common/common.js';
let common = new Common;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    active: 1, //时间
    ranking: 1, //排名
    orgSeq: '',
    infoData: {},
    shopList: {}
  },
  checkDate: function(e) {
    this.setData({
      active: e.currentTarget.dataset.date
    })
    this.getList();
  },
  setRanking: function(e) {
    this.setData({
      ranking: e.currentTarget.dataset.on
    })
    
  },
  /**
   * 生命周期函数--监听页面加载
   */
  getList: function() {
    let data = {
      // orgSeq:this.data.orgSeq,
      // orgSeq:'2e8f4c46-ee3b-4b4b-9270-cf00c28271af',
      flag: this.data.active
    }
    common.requestAjax('/api/trade-service/v1/tradeInfo/queryShopBusinessData?orgSeq=' + this.data.orgSeq + '&flag=' + this.data.active, 'POST').then(res => {
      if (res.data.code == 1) { 
        this.setData({
          infoData: res.data.result
        })
      }
    }).catch(err => {
      console.log(err);
    })
  },

  onLoad: function(options) {
    
  },
  onShow(){
    let orgSeq = app.globalData.orgSeq;

    let orgList = app.globalData.orgList;
    this.setData({
      orgList,
      orgSeq: orgSeq,
      shopList: app.globalData.shopInfo
    })
    this.getList()
  },
  changeShop: function() {
    if (app.globalData.orgList.length > 1) {
      let routeUrl = '/pages/index/chooseShop/index';
      let routeType = 'navigateTo';
      let params = '';
      common.routeLink(routeUrl, params, routeType)
    }
  },
})